//
//  BZ_GHS_TradDetailViewController.m
//  penzer
//
//  Created by caiyc on 2018/11/20.
//  Copyright © 2018年 caiyc. All rights reserved.
// 

#import "BZ_GHS_TradDetailViewController.h"
#import "BZ_GHS_TradDetaiCell.h"
#import "BZ_GHS_DetailHead.h"
#import "BZ_GHS_DrawDetailViewController.h"
#import "SPSection.h"

@interface BZ_GHS_TradDetailViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic,strong) SPSection *sec;

@end

@implementation BZ_GHS_TradDetailViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"提现明细";
    [self setupTableView];
    
}


-(void)setupTableView
{
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([BZ_GHS_TradDetaiCell class]) bundle:nil]  forCellReuseIdentifier:NSStringFromClass([BZ_GHS_TradDetaiCell class])];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.estimatedRowHeight = 140;
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
}


-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 44.0f;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    BZ_GHS_DetailHead *headerV = [BZ_GHS_DetailHead shareHradView];
    headerV.arrow.highlighted = self.sec.open;
    headerV.itemOnClickBlock = ^(BOOL selected) {
        self.sec.open = selected;
        [tableView reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationAutomatic];
    };
    return headerV;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.sec.open?5:0;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    BZ_GHS_TradDetaiCell *cell =[tableView dequeueReusableCellWithIdentifier:NSStringFromClass([BZ_GHS_TradDetaiCell class])];
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    BZ_GHS_DrawDetailViewController *vc = [BZ_GHS_DrawDetailViewController new];
    vc.type = 1;
    [self.navigationController pushViewController:vc animated:NO];
}


#pragma mark--getter&&setter
- (SPSection *)sec
{
    if(!_sec){
        _sec = [SPSection new];
        _sec.items = [NSMutableArray array];
        _sec.open = YES;
    }
    return _sec;
}


@end
